﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Freedom.Models.Interfaces;
using Freedom.Models.Services;
using Freedom.Models.Entities;

namespace Freedom.Models.ViewModels
{
    /// <summary>
    /// 基础视图模型
    /// autor:Penn Yao
    /// </summary>
    public class BaseViewModel
    {
        IFreedomInfoService freedomInfoService;
        IContactInfoService contactInfoService;
        IBlogInfoService blogInfoService;

        public BaseViewModel()
        {
            if (freedomInfoService == null)
                freedomInfoService = new FreedomInfoService();
            if (contactInfoService == null)
                contactInfoService = new ContactInfoService();
            if (blogInfoService == null)
                blogInfoService = new BlogInfoService();

            init();
        }

        /// <summary>
        /// 初始化
        /// </summary>
        public void init()
        {
            if (freedomInfoService != null)
                freedomInfo = freedomInfoService.getInfo(1);
            if (contactInfoService != null)
                contactInfo = contactInfoService.getInfo(1);
            if (blogInfoService != null)
                blogInfoList = blogInfoService.getAllInfo(2);
        }

        /// <summary>
        /// 自由信息
        /// </summary>
        public tb_FreedomInfo freedomInfo { get; set; }

        /// <summary>
        /// 联系信息
        /// </summary>
        public tb_ContactInfo contactInfo { get; set; }

        /// <summary>
        /// 博客信息列表
        /// </summary>
        public List<BlogInfo> blogInfoList { get; set; }
    }
}